{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Autokeras_Titanic.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "iGEzMrP7DzOO",
        "colab_type": "text"
      },
      "source": [
        "First install autokeras from pip"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "eY35wv7Uyvbz",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!pip install autokeras"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "jSoV8IOlFlke",
        "colab_type": "text"
      },
      "source": [
        "Now install Tensorflow GPU"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "C3GQpVLrFpCM",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!pip install tensorflow-gpu==2.1.0"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "PPZgC1JdD6NB",
        "colab_type": "text"
      },
      "source": [
        "Download datasets from Github"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "zU-xtnShDdjm",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!wget https://raw.githubusercontent.com/keras-team/autokeras/master/tests/fixtures/titanic/train.csv\n",
        "!wget https://raw.githubusercontent.com/keras-team/autokeras/master/tests/fixtures/titanic/eval.csv"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4PCynrASD_hA",
        "colab_type": "text"
      },
      "source": [
        "import autokeras"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1IMvNhwYynLx",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import autokeras as ak"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TdSaPDJCECTQ",
        "colab_type": "text"
      },
      "source": [
        "Initialize the classifier."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "grv77LqxzIqG",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "clf = ak.StructuredDataClassifier(max_trials=10)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "sB-dvwNrEHTf",
        "colab_type": "text"
      },
      "source": [
        "fit dataset to model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "LtCkQMa6DlJY",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "clf.fit(x='train.csv', y='survived')"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7davBFSIEKJG",
        "colab_type": "text"
      },
      "source": [
        "get accuracy from trained model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "yjxyIzarDofC",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "print('Accuracy: {accuracy}'.format(\n",
        "    accuracy=clf.evaluate(x='eval.csv', y='survived')))"
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}